<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title th:text="@{{name} launcher(name=${app.name})}"></title>
    <link rel="stylesheet" href="site.css">
</head>
<body>

<header th:replace="base.html :: header"></header>

<main>
    <h2 th:text="${app.name}">App Name</h2>

    <div class="app-screenshot">
        <a href="/" th:href="${app.url}"><img th:src="@{screenshots?url={url}(url=${app.url})}"></a>
        <br><a th:href="@{screenshots?refresh=true&url={url}(url=${app.url})}">(refresh)</a>
    </div>

    <table class="systemTable">
        <tbody>
        <tr>
            <th>Status</th>
            <td><strong th:text="${app.availableStatus}">availability</strong></td>
        </tr>
        <tr>
            <th>Host</th>
            <td><code th:text="${app.host}">host</code> (<a href="/app-runner-home/system">more info</a>)</td>
        </tr>
        <tr>
            <th>API</th>
            <td><a th:href="@{{baseUrl}/api/v1/apps/{id}(id=${app.name},baseUrl=${baseUrl})}" th:text="*{app.host}? 'see here'">host</a></td>
        </tr>
        </tbody>
    </table>

    <h5>Contributors: <span th:text="${app.contributors}"></span></h5>
    <ul class="app-actions">
        <li><a href="/" th:href="${app.url}">Launch app &gt;&gt;</a></li>
        <li><a href="/" th:href="${app.buildLogUrl}">Build logs &gt;&gt;</a></li>
        <li><a href="/" th:href="${app.consoleLogUrl}">Console logs &gt;&gt;</a></li>
    </ul>


    <h3>Contribute</h3>

    <p>Clone <code th:text="${app.gitUrl}"></code> and push your changes.</p>

    <div th:if="${app.lastBuild}" th:class="${'lastBuild ' + app.lastBuild.status}" th:with="commit=${app.lastBuild.commit}">
        <h3>Last build</h3>
        <span th:if="${app.lastBuild.runnerId}" th:text="${'Build type: ' + app.lastBuild.runnerId + '.'}">Build type: maven.</span>
        <span class="lastBuildDescription" th:text="${app.lastBuild.description}">Complete success</span><br>
        Git commit <code th:text="${commit.id}">2b0ebfefd637f4a64fad0686315faf17932af2cd</code> by <span th:text="${commit.author}">Author Name</span>
        on <time th:text="${commit.dateISO}">some time</time>:
        <pre th:text="${commit.message}">Commit message</pre>
    </div>

    <h3>Deploy</h3>
    <p>Make a POST request to <code th:text="${app.deployUrl}"></code> or run it now:</p>

    <form th:action="${app.deployUrl}" method="POST" class="deploy-form">
        <input type="submit" value="Deploy now">
        <pre class="output"></pre>
    </form>


</main>

<footer th:replace="base.html :: footer"></footer>

</body>
<script src="deploy.js"></script>
</html>
